﻿using Microsoft.AspNetCore.Http;
using SXICE.AdminAPI.Models;
using SXICE.Core.Helpers;
using SXICE.Core.Models.DTOs;
using SXICE.IService.Models;
using System;

namespace SXICE.AdminAPI.Utilities
{
    /// <summary>
    /// 工作上下文
    /// </summary>
    public class WorkContext
    {
        /// <summary>
        /// 医生声明
        /// </summary>
        public static DoctorClaimsPrincipal DoctorClaims
        {
            get
            {
                var httpContext = RuntimeHelper.Resolve<IHttpContextAccessor>();
                return httpContext.HttpContext.User.ToEntity<DoctorClaimsPrincipal>();
            }
        }

        /// <summary>
        /// 转换成医生DTO
        /// </summary>
        public static DoctorDTO ToDoctor
        {
            get
            {
                return new DoctorDTO
                {
                    Id = DoctorClaims.UserId,
                    RoleId = DoctorClaims.RoleId,
                };
            }
        }
    }
}
